clear
rng default

%% Load useful matrices
load PYX_cond 
load U_CS
x=1;
PYX_cond_x=PYX_cond(x,:);
%m=1*10^6;
n=7^4;
p=n*(n-1)/2;
m=p;
random_indices_pairs = randperm(p, m).';
%% Construct grid
u0grid=0;
u1grid=U_CS(1,1); 
gran=100;
u2grid=linspace(U_CS(1,2)-500,U_CS(1,2)+500,gran); 
u3grid=linspace(U_CS(1,3)-500,U_CS(1,3)+500,gran); 
u4grid=linspace(U_CS(1,4)-500,U_CS(1,4)+500,gran); 
[ca, cb, cc,cd, ce] = ndgrid(u0grid, u1grid, u2grid, u3grid, u4grid);
u0grid=ca(:);
u1grid=cb(:);
u2grid=cc(:);
u3grid=cd(:);
u4grid=ce(:);

%% Workers
workers=500; %number of parallel workers
jobs=round(size(u2grid,1)/workers); %number of jobs per parallel worker

